<!DOCTYPE html>
<html>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <head>
<!--
Copyright 2009 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
    <title>Custom Loader Image</title>
    <!-- *** Replace the key below below with your own API key, available at http://code.google.com/apis/maps/signup.html *** -->
    <script src="http://www.google.com/jsapi?key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw"></script>
        
    <style>
      html, body { background-color: #000; }
      
      /* target loading div and its near ancestors */
      #map3d div { background-color: #000 !important; }
      
      /* reset color for balloons
         NOTE that balloon.setBackgroundColor('#rrggbb') won't work anymore
         because of CSS !important
      */
      #map3d div div div { background-color: #fff !important; }
    </style>
    <script>
google.load("earth", "1");

var ge = null;

var appPath = document.location.href.replace(/\/[^\/]*$/, '/');

function init() {
  // NOTE: Transparent PNG's don't work in Internet Explorer 6
  // WARNING: setLoadingImageUrl is undocumented and not officially
  //          supported, as of Jul 9 2009.
  google.earth.setLoadingImageUrl(appPath + 'tip_loading.png');
  google.earth.createInstance("map3d", initCallback, failureCallback);
}

function initCallback(pluginInstance) {
  ge = pluginInstance;
  ge.getWindow().setVisibility(true);

  // Create the loading overlay.
  var continueImage = ge.createIcon('');
  continueImage.setHref(appPath + 'tip_continue.png');

  var continueOverlay = ge.createScreenOverlay('');
  continueOverlay.setIcon(continueImage);
  continueOverlay.getOverlayXY().set(0.5, ge.UNITS_FRACTION, 0.5, ge.UNITS_FRACTION);
  continueOverlay.getScreenXY().set(0.5, ge.UNITS_FRACTION, 0.5, ge.UNITS_FRACTION);
  continueOverlay.getSize().set(-1, ge.UNITS_FRACTION, -1, ge.UNITS_FRACTION);
  ge.getFeatures().appendChild(continueOverlay);
  
  var continueFn;
  continueFn = function() {
    ge.getFeatures().removeChild(continueOverlay);
    google.earth.removeEventListener(ge.getWindow(), 'mousedown', continueFn);
  };
  
  google.earth.addEventListener(ge.getWindow(), 'mousedown', continueFn);
}

function failureCallback(object) {
}

function showBalloon() {
  // NOTE that balloon.setBackgroundColor('#rrggbb') won't work anymore
  // because of CSS !important
  
  // test to make sure balloons are still white
  var balloon = ge.createHtmlStringBalloon('');
  balloon.setContentString('Hello World!');
  ge.setBalloon(balloon);
}
    </script>
  </head>
  <body onload='init()' id='body'>
    <center>
      <div>
        Custom Loader Image
      </div>

      <div id="map3d" style="height: 600px; width: 800px;"></div>
      
      <input type="button" value="Show a Balloon" onclick="showBalloon()"/>
    </center>
  </body>
</html>
